import { reactive, ref, computed } from 'v3-mini';

export const dpr = wx.getSystemInfoSync().pixelRatio;

export const system = reactive({
    width: wx.getStorageSync('m-width') || 1080, // 屏幕宽度
    height: wx.getStorageSync('m-height') || 2340, // 屏幕高度
    diagonal: wx.getStorageSync('m-diagonal') || 6.39, // 屏幕尺寸
})

// dpi/ppi
export const dpi = computed(() => Math.sqrt(system.height ** 2 + system.width ** 2) / system.diagonal)

export const ratio = ref(dpi.value / dpr / 96) // 和显示长度的倍数相差

export function resetRatio() {
    ratio.value = dpi.value / dpr / 96
}